package com.biaobiaoqi.scoreanalysis.administrator.action;

import java.util.Date;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.biaobiaoqi.scoreanalysis.exception.DuplicateExaminationException;
import com.biaobiaoqi.scoreanalysis.service.IExaminationService;
import com.biaobiaoqi.scoreanalysis.util.SchoolType;
import com.opensymphony.xwork2.ActionSupport;

public class AddExam extends ActionSupport {
	private static final long serialVersionUID = 4630411220317282538L;
	private static final Log log = LogFactory.getLog(AddExam.class);
	private SchoolType schoolType;
	private int clazzType;
	private String examName;
	private int schoolYear;
	private Date date;

	@Resource
	IExaminationService examinationService;
	
	public String execute() {
		log.debug("schoolType:" + schoolType + " clazzType:" + clazzType
				+ " examName:" + examName + "schollYear:" + schoolYear
				+ " schoolType:" + schoolType + " date:" + date);
		try {
			examinationService.addExamination(examName, date, schoolYear, clazzType, schoolType);
			return SUCCESS;
		} catch (DuplicateExaminationException e) {
			log.debug("add exam failed.", e);
			return INPUT;
		} catch (Exception e) {
			log.error("add exam failed.", e);
			return ERROR;
		}
	}

	public SchoolType getSchoolType() {
		return schoolType;
	}

	public void setSchoolType(SchoolType schoolType) {
		this.schoolType = schoolType;
	}

	public int getClazzType() {
		return clazzType;
	}

	public void setClazzType(int clazzType) {
		this.clazzType = clazzType;
	}

	public String getExamName() {
		return examName;
	}

	public void setExamName(String examName) {
		this.examName = examName;
	}

	public int getSchoolYear() {
		return schoolYear;
	}

	public void setSchoolYear(int schoolYear) {
		this.schoolYear = schoolYear;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}
}
